<template>
  <d2-container :filename="filename">
    <template slot="header">Page 3 header</template>
      <div>
          <div>这是首页</div>
          <a href="javascript:void(0)" @click="addRoutes1">动态添加路由</a> <br>
          <router-link to="/dynamic">前往动态路由 dynamic</router-link>  <br>
          <router-link to="/nouse">前往动态路由 nouse</router-link>  <br>


          <!--binding.arg = function -->
          <el-button-group>
              <el-button  v-permission:function="['p_menu111_edit']" type="primary" icon="el-icon-edit" size="mini">权限测试按钮1</el-button>
              <el-button  v-permission:function="['p_menu_edit']" type="primary" icon="el-icon-edit" size="mini">权限测试按钮2</el-button>
          </el-button-group>
      </div>
  </d2-container>
</template>

<script>
    import routerMapComponents from '@/routerMapComponents' //路由与组件映射关系

    export default {
        name: 'page3',
        data () {
            return {
                filename: __filename
            }
        },
        methods: {
            addRoutes1() {
                this.$router.addRoutes([
                    { name: "dynamic",path: "/dynamic",component: routerMapComponents["dynamic"] },
                    { name: "nouse",path: "/nouse",component: routerMapComponents["nouse"] }
                ]);
                alert("路由添加成功!");
            }
        }
    }
</script>
